package no.ntnu.fp.model;

import java.util.HashMap;
import java.util.Map;

import no.ntnu.fp.net.Connection;

public abstract class AbstractModel implements Packable {
	
	/**
	 * @uml.property name="id"
	 */
	protected int id;

	/**
	 * Getter of the property <tt>id</tt>
	 * 
	 * @return Returns the id.
	 * @uml.property name="id"
	 */
	public int getId() {
		return id;
	}
	
	static protected Connection connection;

	/**
	 * 
	 * 
	 * @param map
	 * @return
	 */
	protected void updateFromMap(Map<String, Object> map) {
		this.getClass();

	}
	
	protected void writeAttribute(String attr, Object value) {
		
	}
	
	@Override
	public void unpack(Map<String, Object> data) {
		for(String k : data.keySet()) {
			writeAttribute(k, data.get(k));
		}
	}

	/**
	 * @param map
	 */
	protected void update(Map<String, Object> map) {

	}
	
	protected Map<String, Object> createAttributeMap() {
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("id", id);
		return m;
	}
}
